<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>组件的嵌套</title>
		<!-- 引入Vue -->
		<script type="text/javascript" src="../js/vue.js"></script>
	</head>
	<body>
		<!-- 

		-->
		<div id="root">
			
		</div>
	</body>
	<script type="text/javascript">
		Vue.config.productionTip = false 
		// student组件
		const student = Vue.extend({
			template: `
				<div>
					<h2>学生名字：{{studentName}}</h2>
					<h2>学生年龄：{{age}}</h2>
				</div>
			`,
			data(){
				return {studentName: "张三",age: 22}
			}
		})
		// school组件
		const school = Vue.extend({
			template: `
				<div>
					<h2>学校名称：{{schoolName}}</h2>
					<h2>学校地址：{{address}}</h2>
					<!-- 使用嵌套的子组件 -->
					<student></student>
				</div>
			`,
			data(){
				return {schoolName: "广技师",address: "广州天河区"}
			},
			// 在组件中嵌套组件
			components:{
				student
			}
		})
		
		// app组件
		const app = Vue.extend({
			template: `
				<div>
					<school></school>
				</div>
			`,
			components:{
				school
			}
		})
		// 创建Vue实例
		new Vue({
			el: "#root",
			template:`<app></app>`,
			components:{
				app,
			}
		})
	</script>
</html>